﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSqlAnalyzer.util
{
	// Token: 0x02000077 RID: 119
	public class keywordChecker
	{
		// Token: 0x060002DE RID: 734 RVA: 0x002F8BAE File Offset: 0x002F6DAE
		private keywordChecker()
		{
		}

		// Token: 0x060002DF RID: 735 RVA: 0x002F8BB8 File Offset: 0x002F6DB8
		public static bool isKeyword(string inputString, EDbVendor dbvendor, string dbVersion, bool reservedOnly)
		{
			if (inputString == null || inputString.Trim().Equals(""))
			{
				return false;
			}
			string item = inputString.ToUpper();
			keywordList dbKeywordList = keywordListFactory.Instance.getDbKeywordList(dbvendor, dbVersion);
			if (dbKeywordList == null)
			{
				throw new ArgumentException("Can't get available keyword list");
			}
			if (reservedOnly)
			{
				return dbKeywordList.ReservedList.Contains(item);
			}
			return dbKeywordList.KeywordList.Contains(item);
		}

		// Token: 0x060002E0 RID: 736 RVA: 0x002F8C1C File Offset: 0x002F6E1C
		public static string getKeywordList(EDbVendor dbvendor, string dbVersion, bool reservedOnly)
		{
			keywordList dbKeywordList = keywordListFactory.Instance.getDbKeywordList(dbvendor, dbVersion);
			if (dbKeywordList == null)
			{
				throw new ArgumentException("Can't get available keyword list");
			}
			List<string> list;
			if (reservedOnly)
			{
				list = dbKeywordList.ReservedList;
			}
			else
			{
				list = dbKeywordList.KeywordList;
			}
			if (list != null)
			{
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < list.Count; i++)
				{
					if (i < list.Count - 1)
					{
						stringBuilder.Append(list[i]).Append(",");
					}
					else
					{
						stringBuilder.Append(list[i]);
					}
				}
				return stringBuilder.ToString();
			}
			return null;
		}

		// Token: 0x060002E1 RID: 737 RVA: 0x002F8CB0 File Offset: 0x002F6EB0
		public static string compareKeywordList(EDbVendor dbvendor1, string dbVersion1, EDbVendor dbvendor2, string dbVersion2, bool reservedOnly)
		{
			keywordList dbKeywordList = keywordListFactory.Instance.getDbKeywordList(dbvendor1, dbVersion1);
			keywordList dbKeywordList2 = keywordListFactory.Instance.getDbKeywordList(dbvendor2, dbVersion2);
			if (dbKeywordList == null || dbKeywordList2 == null)
			{
				throw new ArgumentException("Can't get available keyword list");
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			List<string> list3 = new List<string>();
			if (reservedOnly)
			{
				list3.AddRange(dbKeywordList.ReservedList);
				CollectionUtil<string>.retainAll(list3, dbKeywordList2.ReservedList);
				list.AddRange(dbKeywordList.ReservedList);
				list2.AddRange(dbKeywordList2.ReservedList);
			}
			else
			{
				list3.AddRange(dbKeywordList.KeywordList);
				CollectionUtil<string>.retainAll(list3, dbKeywordList2.KeywordList);
				list.AddRange(dbKeywordList.KeywordList);
				list2.AddRange(dbKeywordList2.KeywordList);
			}
			CollectionUtil<string>.removeAll(list, list3);
			CollectionUtil<string>.removeAll(list2, list3);
			for (int i = 0; i < list2.Count; i++)
			{
				list.Add("-" + list2[i]);
			}
			list.Sort(new keywordChecker.ComparatorAnonymousInnerClass());
			StringBuilder stringBuilder = new StringBuilder();
			for (int j = 0; j < list.Count; j++)
			{
				stringBuilder.Append(list[j]);
				if (j < list.Count - 1)
				{
					stringBuilder.Append(",");
				}
			}
			return stringBuilder.ToString();
		}

		// Token: 0x060002E2 RID: 738 RVA: 0x002F8DF9 File Offset: 0x002F6FF9
		public static List<string> getAvailableDbVersions(EDbVendor dbvendor)
		{
			return keywordListFactory.Instance.getAvailableDbVersions(dbvendor);
		}

		// Token: 0x060002E3 RID: 739 RVA: 0x002F8E06 File Offset: 0x002F7006
		public static bool containsDbVersion(EDbVendor dbvendor, string dbVersion)
		{
			return keywordListFactory.Instance.containsDbVersion(dbvendor, dbVersion);
		}

		// Token: 0x04001086 RID: 4230
		private const string COMMA = ",";

		// Token: 0x04001087 RID: 4231
		private const string MINUS = "-";

		// Token: 0x02000435 RID: 1077
		private class ComparatorAnonymousInnerClass : IComparer<string>
		{
			// Token: 0x06002960 RID: 10592 RVA: 0x0033E378 File Offset: 0x0033C578
			public virtual int Compare(string str1, string str2)
			{
				if (!str1.StartsWith("-", StringComparison.Ordinal))
				{
					str1 = "-" + str1;
				}
				if (!str2.StartsWith("-", StringComparison.Ordinal))
				{
					str2 = "-" + str2;
				}
				return string.Compare(str1, str2, StringComparison.OrdinalIgnoreCase);
			}
		}
	}
}
